﻿@{
    ViewBag.Title = "Column resizing demo";
}
<div id="StudentTableContainer">
</div>
<script type="text/javascript">

    $(document).ready(function () {

        $('#StudentTableContainer').jtable({
            tableId: 'MyResizableTable',
            title: 'Student List',
            paging: true,
            pageSize: 10,
            sorting: true,
            //columnResizable: true, //No need to set true since it's default.
            defaultSorting: 'Name ASC',
            actions: {
                listAction: '@Url.Action("StudentList")',
                deleteAction: '@Url.Action("DeleteStudent")',
                updateAction: '@Url.Action("UpdateStudent")',
                createAction: '@Url.Action("CreateStudent")'
            },
            fields: {
                StudentId: {
                    key: true,
                    create: false,
                    edit: false,
                    title: 'Id',
                    width: '5%',
                    sorting: false,
                    list: false
                },
                Name: {
                    title: 'Name',
                    width: '20%'
                },
                EmailAddress: {
                    title: 'Email address',
                    width: '20%',
                    list: false
                },
                Password: {
                    title: 'User Password',
                    type: 'password',
                    list: false
                },
                Gender: {
                    title: 'Gender',
                    width: '13%',
                    options: { 'M': 'Male', 'F': 'Female' },
                    list: false
                },
                CityId: {
                    title: 'City',
                    width: '12%',
                    options: '@Url.Action("GetCityOptions")',
                    list: false
                },
                BirthDate: {
                    title: 'Birth date',
                    width: '30%',
                    type: 'date',
                    displayFormat: 'yy-mm-dd'
                },
                Education: {
                    title: 'Education',
                    list: false,
                    type: 'radiobutton',
                    options: { '1': 'Primary school', '2': 'High school', '3': 'University' }
                },
                About: {
                    title: 'About this person',
                    type: 'textarea',
                    list: false
                },
                IsActive: {
                    title: 'Status',
                    width: '12%',
                    type: 'checkbox',
                    values: { 'false': 'Passive', 'true': 'Active' },
                    defaultValue: 'true',
                    list: false
                },
                RecordDate: {
                    title: 'Record date',
                    width: '30%',
                    type: 'date',
                    displayFormat: 'yy-mm-dd',
                    create: false,
                    edit: false,
                    sorting: false //This column is not sortable!
                }
            }
        });

        //Load student list from server
        $('#StudentTableContainer').jtable('load');

    });

</script>

